package kr.hkit.powerjava.chapter13;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JSplitPane;

import java.awt.FlowLayout;

import javax.swing.JButton;

import java.awt.Toolkit;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class WindowBuilder_FrameTest extends JFrame {

	private JPanel contentPane;
	private JTextField jtf01;
	private JTextField jtf02;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					WindowBuilder_FrameTest frame = new WindowBuilder_FrameTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public WindowBuilder_FrameTest() {
		Toolkit tool = Toolkit.getDefaultToolkit();
		Dimension screenSize = tool.getScreenSize();
		Dimension frameSize = new Dimension(450, 300);

		int x = (int) (screenSize.getWidth()/2 - frameSize.getWidth()/2);
		int y = (int) (screenSize.getHeight()/2 - frameSize.getHeight()/2);

		
		setIconImage(Toolkit.getDefaultToolkit().getImage(WindowBuilder_FrameTest.class.getResource("/sun/print/resources/duplex.png")));
		setTitle("윈도우 빌더 - 테스트");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setBounds(x,y,(int)frameSize.getWidth(), (int)frameSize.getHeight());
		//setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		JPanel mainPanel = new JPanel();
		contentPane.add(mainPanel);
		
		JButton btn01 = new JButton("버튼1");
		mainPanel.add(btn01);
		
		JButton btn02 = new JButton("버튼2");
		mainPanel.add(btn02);
		remove(btn02);
		
		JPanel tfPanel = new JPanel();
		contentPane.add(tfPanel);
		
		jtf01 = new JTextField();
		tfPanel.add(jtf01);
		jtf01.setColumns(10);
		
		jtf02 = new JTextField();
		jtf02.setEditable(false);
		jtf02.setHorizontalAlignment(SwingConstants.CENTER);
		jtf02.setText("test");
		tfPanel.add(jtf02);
		jtf02.setColumns(10);
		pack();
	}

}
